<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/frameset.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<STYLE type=text/css>
BODY {
	FONT-SIZE: 12px;
	COLOR: #ffffff;
	FONT-FAMILY: 宋体
}

TD {
	FONT-SIZE: 12px;
	COLOR: #ffffff;
	FONT-FAMILY: 宋体
}
</STYLE>

<META content="MSHTML 6.00.6000.16809" name=GENERATOR>
<script>
	// 定义javascript函数
	function checkForm()
	{
		// 获取密码框 重复密码框里的内容
		var pass1 = document.getElementById("pass1").value;
		var pass2 = document.getElementById("pass2").value;	
		console.log(pass1);
		console.log(pass2);
		if(pass1==pass2)
		{
			return true;
		}
		else
		{
			alert("密码不一致");
			return false;	
		}
	}
	
	// ajax对象
	var xmlHttpReq;
	
	function checkName()
	{
		// 1. 获取用户填写用户名
		var username = document.getElementById("txtName").value;
		
		// 2. 创建ajax对象
		xmlHttpReq = new XMLHttpRequest();
		
		// 3. 设定处理函数
		xmlHttpReq.onreadystatechange = handle;
		
		
		// 4. 发送请求
		var url = "checkname?username="+username;
		xmlHttpReq.open("get",url,true); // true 表示 异步 false 同步
		xmlHttpReq.send(null);
		
	}
	
	function handle()
	{
		if(xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200)
		{
			console.log(xmlHttpReq.responseText);
			
			var usernameInfo = document.getElementById("usernameInfo");
			console.log(usernameInfo);
			
			var data = JSON.parse(xmlHttpReq.responseText);
			if(data.result==1)
			{
				usernameInfo.innerHTML = "用户名不可用"	
			}
			else
			{
				usernameInfo.innerHTML = "";
			}
			 
			
		}
	}
</script>
</HEAD>
<BODY>
	<FORM id=form1 name=form1 action="registerchk" method="post" onsubmit="return checkForm()">

		<DIV id=UpdatePanel1>
			<DIV id=div1
				style="LEFT: 0px; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: #0066ff"></DIV>
			<DIV id=div2
				style="LEFT: 0px; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: #0066ff"></DIV>


			<DIV>&nbsp;&nbsp;</DIV>
			<DIV>
				<TABLE cellSpacing=0 cellPadding=0 width=900 align=center border=0>
					<TBODY>
						<TR>
							<TD style="HEIGHT: 105px"><IMG src="images/login_1.gif"
								border=0></TD>
						</TR>
						<TR>
							<TD background=images/login_2.jpg height=300>
								<TABLE height=300 cellPadding=0 width=900 border=0>
									<TBODY>
										<TR>
											<TD colSpan=2 height=35></TD>
										</TR>
										<TR>
											<TD width=360></TD>
											<TD>
												<TABLE cellSpacing=0 cellPadding=2 border=0>
													<TBODY>
														<TR>
															<TD style="HEIGHT: 28px" width=80>用 户 名：</TD>
															<TD style="HEIGHT: 28px" width=150>
																<INPUT id=txtName style="WIDTH: 130px" name="username" onKeyUp="checkName()"></TD>
															<TD style="HEIGHT: 28px" width=370><SPAN
																id='usernameInfo'
																style="FONT-WEIGHT: bold;  COLOR: white">111</SPAN></TD>
														</TR>
														<TR>
															<TD style="HEIGHT: 28px">密 码：</TD>
															<TD style="HEIGHT: 28px">
																<INPUT id=pass1 style="WIDTH: 130px" type=password name="password"></TD>
															<TD style="HEIGHT: 28px"><SPAN
																id=RequiredFieldValidator4
																style="FONT-WEIGHT: bold; VISIBILITY: hidden; COLOR: white">请输入密码</SPAN></TD>
														</TR>
														<TR>
															<TD style="HEIGHT: 28px">重复密码：</TD>
															<TD style="HEIGHT: 28px"><INPUT id=pass2
																style="WIDTH: 130px" name=txtcode></TD>
															<TD style="HEIGHT: 28px">&nbsp;</TD>
														</TR>
														<TR>
															<TD style="HEIGHT: 18px"></TD>
															<TD style="HEIGHT: 18px"></TD>
															<TD style="HEIGHT: 18px"></TD>
														</TR>
														<TR>
															<TD></TD>
															<TD><INPUT id=btn
																style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px"
																type=submit src="images/login_button.gif" name=btn
																value="注册">
															</TD>
														</TR>
													</TBODY>
												</TABLE>
											</TD>
										</TR>
									</TBODY>
								</TABLE>
							</TD>
						</TR>
						<TR>
							<TD><IMG src="images/login_3.jpg" border=0></TD>
						</TR>
					</TBODY>
				</TABLE>
			</DIV>
		</DIV>


	</FORM>
</BODY>
</HTML>


</body>
</html>